---------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Dropbox\bavarian affair\merged data\replication\survey\survey_2014.log
  log type:  text
 opened on:  20 Nov 2015, 18:53:20

. 
. **********************
. *** Treatment vars ***
. **********************
. 
. use "tables\aggregate_treat.dta", clear 

. drop if  year!=2013
(90 observations deleted)

. 
. keep nr affair_run affair_norun

. ren nr stk_num

. save "survey\tmp.dta", replace
file survey\tmp.dta saved

. * district is district-number-2013 here
. 
. **************
. *** Survey ***
. **************
. 
. use "survey\medw_raw.dta", clear

. 
. drop if POST_COMPLETE_W2 == 0 // completed Bavaria post-elec wave: 4697 cases
(1,209 observations deleted)

. 
. *** Stimmkreis/SMD number 
. destring VARC, replace
VARC has all characters numeric; replaced as int

. * NOTE: VARC is labeled as 'national electoral district', but the variable label is i
> ncorrect in the raw data (the id for the 45 national election district is in VARB)
. so VARC

. ren VARC stk_num 

. mvdecode stk_num, mv(999)
     stk_num: 380 missing values generated

. count if stk_num == . // N=380
  380

. di r(N)/_N // 8.1%
.0809027

. drop if stk_num == . // remain: N=4317
(380 observations deleted)

. 
. 
. **************************
. *** Add treatment vars ***
. **************************
. 
. merge m:1 stk_num using "survey\tmp.dta"
(note: variable stk_num was int, now float to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                             4,317  (_merge==3)
    -----------------------------------------

. drop _m

. erase "survey\tmp.dta"

. 
. *************************
. *** indepvars ***********
. *************************
. 
. ** create alternative-specific vars in long format
. 
. * Party id and party most competent dummies
. forvalues i = 1/6 {
  2. gen pid`i' = 0 if Q46_W1 != . // create pid var if pid question answered
  3. replace pid`i' = 1 if Q46_W1 == 1 & Q46A_W1 == `i' & (Q46B_W1 == 2 | Q46B_W1 == 3)
>  // 1 if pid yes and feeling somewhat close or very close to party (not if only 'not 
> very close' or don't know)
  4. gen bestdeal`i' = 0  // best party to deal with most imp issue ; consider missing 
> as 0
  5. replace bestdeal`i' = 1 if Q3B_W1 == `i' 
  6. }
(850 real changes made)
(874 real changes made)
(281 real changes made)
(363 real changes made)
(123 real changes made)
(223 real changes made)
(34 real changes made)
(43 real changes made)
(35 real changes made)
(73 real changes made)
(32 real changes made)
(76 real changes made)

. * left-right distance
. mvdecode Q30A_W1 Q30A?_W1, mv(99)
     Q30A_W1: 465 missing values generated
    Q30AA_W1: 607 missing values generated
    Q30AB_W1: 616 missing values generated
    Q30AC_W1: 683 missing values generated
    Q30AD_W1: 908 missing values generated
    Q30AE_W1: 705 missing values generated
    Q30AF_W1: 556 missing values generated
    Q30AG_W1: 1143 missing values generated

. local letters "A B C D E F"

. forvalues i = 1/6 {
  2. local l : word `i' of `letters'
  3. egen lrpmean`i' =  mean(Q30A`l'_W1)
  4. gen lrdistm`i' = abs(Q30A_W1-lrpmean`i')
  5. }
(465 missing values generated)
(465 missing values generated)
(465 missing values generated)
(465 missing values generated)
(465 missing values generated)
(465 missing values generated)

. 
. 
. ** create respondent-specific vars
. 
. *economic voting 
. * have policies of Land government made economy better? 
. * 1 worse 2 not made a difference 3 better 9 don't know
. gen govecopos = Q15A_W1 // dummy for positive evaluation

. recode govecopos (3 = 1) (nonmiss = 0) //   (code dont' know as zero)
(govecopos: 4317 changes made)

. gen goveconeg = Q15A_W1 // dummy for negative evaluation

. recode goveconeg (1 = 1) (nonmiss = 0) //  (code dont' know as zero)
(goveconeg: 3621 changes made)

. 
. * religion
. gen relig = SD3_W1

. recode relig (1 = 1) (2 3 = 2) (4 5 6 88 98 = 3)  (99 . = .) 
(relig: 1585 changes made)

. lab def relig 1 "Catholic" 2 "Protestant" 3     "Other/None"

. * Protestant = Evangelical, Protestant; Evangelical Free Church
. * Other/None = Other Christian; Jewish; Muslim; Other; No Religion.
. * Missing = prefer not to say; missing.
. lab val relig relig

. 
. * union membership dummy
. gen union = PSD1_W2 // anyone in household union member?

. recode union (2 9 = 0) // no and don't know as 0
(union: 3561 changes made)

. 
. * high education level dummy
. gen higheduc = SD4_W1

. recode higheduc ( 1 2 3 =  0) (nonmiss = 1) // one if 'technical high secondary' or h
> igher
(higheduc: 4317 changes made)

. 
. * age categories
. egen resp_agecat = cut(AGE), at(0 30(10)60 100) // >= category label < next cat label

. qui tab resp_agecat, gen(resp_agecat_gr)

. 
. * Franconia dummy
. gen franconia = 0 if stk_num != .

. replace franconia = 1 if stk_num > 399 & stk_num < 700
(1,506 real changes made)

. 
. * politically very interested (dummy)
. gen vintpol = Q5_W1

. recode vintpol (8 9 10 = 1) (1/7 99 = 0) // don't know as zero. three highest categor
> ies as one
(vintpol: 4241 changes made)

. 
. **************************
. *** first vote party   ***
. **************************
. drop if PQ5_2_W2 != 1 // drop those who did not vote or don't know re turnout. N = 35
> 4, remain : 3963.
(354 observations deleted)

. mvdecode PQ6_W2, mv(99) // Don't know their vote choice. N = 287, 7.2%. Set to missin
> g, but keep obs
      PQ6_W2: 287 missing values generated

. drop if stk_num == 712 | stk_num == 206 // drop if SMD ballot didn't have candidates 
> from each of 7 'main' parties (these are non-affair SMDs). lose N=60, 3903 remaining.
(60 observations deleted)

. 
. lab def parties 1       "CSU" 2 "SPD" 3 "Greens" 4 "Free Voters" 5      "FDP" 6 "Left
> " 7 "Pirates" 88   "Other" 98      "Invalid vote"

. lab val PQ6_W2 parties

. tab PQ6_W2 if PQ6_W2 

 PQ6.  Which |
     party's |
   candidate |
did you vote |
        for? |      Freq.     Percent        Cum.
-------------+-----------------------------------
         CSU |      1,659       45.82       45.82
         SPD |        813       22.45       68.27
      Greens |        264        7.29       75.56
 Free Voters |        346        9.56       85.11
         FDP |        115        3.18       88.29
        Left |         90        2.49       90.78
     Pirates |         83        2.29       93.07
       Other |        214        5.91       98.98
Invalid vote |         37        1.02      100.00
-------------+-----------------------------------
       Total |      3,621      100.00

. tab PQ6_W2 if PQ6_W2 != 98 //   Erststimme. Actual: 46.5, 20.4, 8.8, 9.8, 3.3, 2.2, 2
> .0 

 PQ6.  Which |
     party's |
   candidate |
did you vote |
        for? |      Freq.     Percent        Cum.
-------------+-----------------------------------
         CSU |      1,659       46.29       46.29
         SPD |        813       22.68       68.97
      Greens |        264        7.37       76.34
 Free Voters |        346        9.65       85.99
         FDP |        115        3.21       89.20
        Left |         90        2.51       91.71
     Pirates |         83        2.32       94.03
       Other |        214        5.97      100.00
-------------+-----------------------------------
       Total |      3,584      100.00

. 
. gen pfirstvote = PQ6_W2
(282 missing values generated)

. recode pfirstvote (7 88 98 = .a) //  pirates 84, other 220 and invalid 37. Total N=34
> 1, 8.6% Set to missing, but keep obs
(pfirstvote: 334 changes made)

. * voted for 6 parties: %
. gen pfirstvote_not6 = (pfirstvote == .)

. *long format version
. forvalues i = 1/6 {
  2. gen pfirstvote`i' = pfirstvote
  3. recode pfirstvote`i' (`i' = 1) (nonmiss = 0 ) 
  4. }
(616 missing values generated)
(pfirstvote1: 1628 changes made)
(616 missing values generated)
(pfirstvote2: 3287 changes made)
(616 missing values generated)
(pfirstvote3: 3287 changes made)
(616 missing values generated)
(pfirstvote4: 3287 changes made)
(616 missing values generated)
(pfirstvote5: 3287 changes made)
(616 missing values generated)
(pfirstvote6: 3287 changes made)

. 
. **************************
. *** second vote party   **
. **************************
. mvdecode PQ7_W2, mv(98 99) // as missings: don't remember ; Don't know 
      PQ7_W2: 354 missing values generated

. lab val PQ7_W2 parties

. tab PQ7_W2

   PQ7.  The |
candidate of |
 which party |
   (or which |
 party list) |
did you vote |
        for? |      Freq.     Percent        Cum.
-------------+-----------------------------------
         CSU |      1,409       39.70       39.70
         SPD |        769       21.67       61.37
      Greens |        337        9.50       70.87
 Free Voters |        359       10.12       80.98
         FDP |        190        5.35       86.33
        Left |         97        2.73       89.07
     Pirates |         92        2.59       91.66
       Other |        296        8.34      100.00
-------------+-----------------------------------
       Total |      3,549      100.00

. ren PQ7_W2 psecondvote 

. gen psecondcsu = psecondvote
(354 missing values generated)

. recode psecondcsu (1=1) (nonmiss=0)
(psecondcsu: 2140 changes made)

. recode psecondvote (7 88  = .a) //  pirates N= 92, other N= 296.  Set to missing, but
>  keep obs
(psecondvote: 388 changes made)

. * voted for 6 parties: %
. gen psecondvote_not6 = (psecondvote == .)

. *long format version
. forvalues i = 1/6 {
  2. gen psecondvote`i' = psecondvote
  3. recode psecondvote`i' (`i' = 1) (nonmiss = 0 ) 
  4. }
(742 missing values generated)
(psecondvote1: 1752 changes made)
(742 missing values generated)
(psecondvote2: 3161 changes made)
(742 missing values generated)
(psecondvote3: 3161 changes made)
(742 missing values generated)
(psecondvote4: 3161 changes made)
(742 missing values generated)
(psecondvote5: 3161 changes made)
(742 missing values generated)
(psecondvote6: 3161 changes made)

. 
. 
. ******************************************************************
. *** self-report of affair being important for voting decisions ***
. ******************************************************************
. 
. gen affair_vimp = PQ4A_W2 

. *how important were teh following events for your voting decision(s)? Relatives affai
> r in the state-level parliament
. * 4 very imp 3 fairly imp 2 not very imip 1 not imp at all 8 can't remember 9 don't k
> now
. * dummy for very important:
. recode affair_vimp (4 = 1) (nonmiss = 0) // (8 and 9 as zero)
(affair_vimp: 3903 changes made)

. * dummy for important or very important
. gen affair_imp = PQ4A_W2 

. recode affair_imp (3 4 = 1) (nonmiss = 0) // (8 and 9 as zero)
(affair_imp: 3903 changes made)

. 
. 
. *******************************
. *** candidate vote variable ***
. *******************************
. 
. gen wk_num = PQ7_PRE_W2 // regional district number

. * cross-check with first digit from SMD number:
. gen wkfromstk = floor(stk_num/100)

. tab wk_num wkfromstk, row nof

           |                       wkfromstk
    wk_num |         1          2          3          4          5 |     Total
-----------+-------------------------------------------------------+----------
         1 |     98.22       0.51       0.19       0.13       0.06 |    100.00 
         2 |      6.99      91.26       0.70       0.70       0.00 |    100.00 
         3 |      0.32       0.95      97.47       0.95       0.00 |    100.00 
         4 |      0.00       0.28       0.00      98.34       0.83 |    100.00 
         5 |      0.00       0.17       0.17       0.84      98.83 |    100.00 
         6 |      0.00       0.00       0.25       0.25       1.23 |    100.00 
         7 |      1.47       0.00       0.00       0.29       0.00 |    100.00 
        99 |     82.61       0.00       0.00       0.00       4.35 |    100.00 
-----------+-------------------------------------------------------+----------
     Total |     40.76       7.02       8.07       9.48      15.35 |    100.00 


           |       wkfromstk
    wk_num |         6          7 |     Total
-----------+----------------------+----------
         1 |      0.19       0.70 |    100.00 
         2 |      0.00       0.35 |    100.00 
         3 |      0.00       0.32 |    100.00 
         4 |      0.55       0.00 |    100.00 
         5 |      0.00       0.00 |    100.00 
         6 |     98.03       0.25 |    100.00 
         7 |      0.00      98.23 |    100.00 
        99 |      0.00      13.04 |    100.00 
-----------+----------------------+----------
     Total |     10.35       8.97 |    100.00 


. gen wk_inconsistent = 0

. replace wk_inconsistent = 1 if wk_num < 99 & wk_num != wkfrom
(88 real changes made)

. 
. gen secondvote = .
(3,903 missing values generated)

. 
. * NOTE set to missing if there are several inconsistent entries (which still counts a
> s a party vote in a way, ca. N=35 cases)
. forvalues i = 1/7 {
  2. replace PQ7_2`i'_W2M1 = . if (PQ7_2`i'_W2M2 != . & PQ7_2`i'_W2M2 != PQ7_2`i'_W2M1)
>  | (PQ7_2`i'_W2M3 != . & PQ7_2`i'_W2M3 != PQ7_2`i'_W2M1)
  3. replace secondvote = PQ7_2`i'_W2M1 if PQ7_2`i'_W2M1 != .
  4. }
(8 real changes made, 8 to missing)
(1,342 real changes made)
(1 real change made, 1 to missing)
(224 real changes made)
(3 real changes made, 3 to missing)
(257 real changes made)
(2 real changes made, 2 to missing)
(303 real changes made)
(11 real changes made, 11 to missing)
(476 real changes made)
(6 real changes made, 6 to missing)
(317 real changes made)
(3 real changes made, 3 to missing)
(284 real changes made)

. egen test = rownonmiss(PQ7_2?_W2M1) // ok, is never greater  than one

. assert test <=1

. drop test

. 
. gen vote_code = secondvote
(700 missing values generated)

. 
. * merge labels=candidate-names (variable candnumbername)
. merge m:1 wk_num vote_code using "survey\medw_candidatelist_edited"

    Result                           # of obs.
    -----------------------------------------
    not matched                         1,241
        from master                       700  (_merge==1)
        from using                        541  (_merge==2)

    matched                             3,203  (_merge==3)
    -----------------------------------------

. * _m == 1 have vote_code missing
. drop if _m == 2 
(541 observations deleted)

. drop _m 

. 
. *************************** Intermediate step: **************************************
> ********************************
. ** need to remove invalid answers, esp. those referring to SMD-candidate for 2nd vote
>  (who cannot have stood on list in her/his SMD)
. * (questionnaire design didn't prevent that these candidate names could be given as a
> nswers. (some people might also have moved, but timespan bw pre- and postelectoral wa
> ve is short))
. 
. gen party_num = psecondvote
(742 missing values generated)

. recode party_num (88 98 = .)
(party_num: 0 changes made)

. gen name = itrim(candnumbername)
(700 missing values generated)

. forvalues i = 0/9 {
  2. replace name = subinstr(name,"`i'","",.)
  3. }
(2,380 real changes made)
(2,131 real changes made)
(1,127 real changes made)
(518 real changes made)
(483 real changes made)
(324 real changes made)
(214 real changes made)
(242 real changes made)
(105 real changes made)
(68 real changes made)

. 
. replace secondvote = . if psecondvote != 1 // only CSU candidate votes of interest
(1,817 real changes made, 1,817 to missing)

. 
. * look for matches in file with Stkr-candidates (fuzzy match, requires additional ado
> )
. * (only for CSU candidates, others not of interest)
. gen tmpmasterid = _n

. reclink stk_num party_num name using "survey\csu_smd_candidates_2013.dta", ///
>         idmaster(tmpmasterid) idusing(tmpusingid) gen(match) require(stk_num party_nu
> m) minscore(.98) // (picked score after inspection)

0 perfect matches found

Going through 3903 observation to assess fuzzy matches, each .=5% complete
....................
Added: tmpusingid= identifier from survey\csu_smd_candidates_2013.dta   match = matchin
> g score
Observations:  Master N = 3903    survey\csu_smd_candidates_2013.dta N= 90 
  Unique Master Cases: matched = 156 (exact = 0), unmatched = 3747

. * (inspected the fuzzy match and tried different minscore cutoffs)
. tab _m if psecondvote == 1 // among CSU 2nd vote voters: 156 = 11% invalid answers

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      1,253       88.93       88.93
          3 |        156       11.07      100.00
------------+-----------------------------------
      Total |      1,409      100.00

. tab _m if psecondvote == 1 & wk_num != 5 // (excludes district where no implicated ca
> nd on  list)

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      1,086       89.60       89.60
          3 |        126       10.40      100.00
------------+-----------------------------------
      Total |      1,212      100.00

. replace secondvote = . if _merge == 3 // set these invalid answers to missing
(156 real changes made, 156 to missing)

. replace candnumbername = "" if _merge == 3 // set these invalid answers to missing
(156 real changes made)

. 
. drop party_num-_merge

. replace secondvote = . if secondvote == 998 | secondvote == 999 | secondvote == 1 // 
> invalid; don't know; general party vote 
(132 real changes made, 132 to missing)

. ******************* end intermediate step *******************************************
> *********************************************
. 
. * psecondcsu == 1 for N = 1409
. * candidate info for 1098 = 77.9 % 
. count if secondvote != . & psecondcsu == 1
  1,098

. * not available for N=311: party vote 60, invalid 3, don't know 69, missing 179 (incl
> udes 156 stk cand invalid answers; rest should be those with several entries)
. 
. 
. gen rbez = wk_num

. recode rbez (1=3) (2=4) (3=2) (4=6) (5=5) (6=7) (7=1)
(rbez: 3284 changes made)

. 
. 
. gen list_pre = real(word(candnumbername,1)) if psecondvote      == 1
(2,805 missing values generated)

. replace list_pre = mod(list_pre,100) if psecondvote     == 1
(1,098 real changes made)

. sum list_pre

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
    list_pre |      1,098     4.59745    6.456507          1         44

. gen year = 2013

. 
. * now add info for chosen candidate                     
. merge m:m  year rbez list_pre using  "tables\candidates_csu_replication.dta", keepus(
> affair) // NOTE :m is due to missings in year = 2008 in using, irrelevant for here

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,916
        from master                     2,805  (_merge==1)
        from using                        111  (_merge==2)

    matched                             1,098  (_merge==3)
    -----------------------------------------

. * _m == 1: secondvote ==. 
. * _m == 2: cand not mentioned as choice by survey respondents (and 2008 cand from usi
> ng)
. drop year 

. drop if _m == 2
(111 observations deleted)

. drop _m

. 
. 
. keep RESPID wk_num stk_num pfirstvote? psecondvote? pid* bestdeal* lr* goveco* relig 
> franconia union higheduc female resp* affair* vintpol  ///
>     psecondcsu  candnumbername list_pre rbez wk_inconsistent

. 
. reshape long pfirstvote psecondvote pid bestdeal lrdistm, i(RESPID) j(party_num)
(note: j = 1 2 3 4 5 6)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     3903   ->   23418
Number of variables                  63   ->      39
j variable (6 values)                     ->   party_num
xij variables:
pfirstvote1 pfirstvote2 ... pfirstvote6   ->   pfirstvote
psecondvote1 psecondvote2 ... psecondvote6->   psecondvote
                     pid1 pid2 ... pid6   ->   pid
      bestdeal1 bestdeal2 ... bestdeal6   ->   bestdeal
         lrdistm1 lrdistm2 ... lrdistm6   ->   lrdistm
-----------------------------------------------------------------------------

. 
. save "survey\medw_out.dta", replace 
file survey\medw_out.dta saved

. 
. ***************************************************************
. ** estimate conditional logit for party choice with second vote
. ***************************************************************
. 
. global fcontrols "pid bestdeal lrdistm"

. global fcasecntrls "female resp_agecat_gr2-resp_agecat_gr5 higheduc union i.relig fra
> nconia  goveco*"

. 
. xi: asclogit psecondvote $fcontrols , case(RESPID) alt(party_num) base(1) casevars($f
> casecntrls) 
i.relig           _Irelig_1-3         (naturally coded; _Irelig_1 omitted)
note: variable pid has 1665 cases that are not alternative-specific: there is no
      within-case variability
note: variable bestdeal has 1464 cases that are not alternative-specific: there is no
      within-case variability

Iteration 0:   log likelihood =  -9361.322  
Iteration 1:   log likelihood = -7283.7004  
Iteration 2:   log likelihood =  -6598.366  (backed up)
Iteration 3:   log likelihood = -3835.5847  
Iteration 4:   log likelihood = -3474.8542  
Iteration 5:   log likelihood = -2945.2769  
Iteration 6:   log likelihood = -2904.3463  
Iteration 7:   log likelihood =  -2903.766  
Iteration 8:   log likelihood = -2903.7656  
Iteration 9:   log likelihood = -2903.7656  

Alternative-specific conditional logit         Number of obs      =     17,070
Case variable: RESPID                          Number of cases    =       2845

Alternative variable: party_num                Alts per case: min =          6
                                                              avg =        6.0
                                                              max =          6

                                                  Wald chi2(63)   =    1444.30
Log likelihood = -2903.7656                       Prob > chi2     =     0.0000

---------------------------------------------------------------------------------
    psecondvote |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
----------------+----------------------------------------------------------------
party_num       |
            pid |   1.940387   .0953854    20.34   0.000     1.753435    2.127339
       bestdeal |   1.461026   .0797959    18.31   0.000     1.304629    1.617423
        lrdistm |  -.2917115   .0230738   -12.64   0.000    -.3369353   -.2464877
----------------+----------------------------------------------------------------
1               |  (base alternative)
----------------+----------------------------------------------------------------
2               |
         female |  -.2091272   .1319423    -1.58   0.113    -.4677292    .0494749
resp_agecat_gr2 |  -.1330706   .2214578    -0.60   0.548    -.5671199    .3009787
resp_agecat_gr3 |    .151035   .2201547     0.69   0.493    -.2804603    .5825303
resp_agecat_gr4 |   .5016334   .2351443     2.13   0.033      .040759    .9625077
resp_agecat_gr5 |   .7522043    .250579     3.00   0.003     .2610785     1.24333
       higheduc |   .2599433   .1333377     1.95   0.051    -.0013939    .5212804
          union |   .5552046   .1695038     3.28   0.001     .2229833    .8874258
      _Irelig_2 |   .3968927   .1696343     2.34   0.019     .0644156    .7293699
      _Irelig_3 |   .5809187   .1508291     3.85   0.000     .2852991    .8765384
      franconia |  -.2820101   .1392721    -2.02   0.043    -.5549785   -.0090417
      govecopos |  -1.205191   .1662053    -7.25   0.000    -1.530948   -.8794348
      goveconeg |   .1546924   .1812883     0.85   0.393    -.2006262    .5100109
          _cons |  -.5182645   .2412732    -2.15   0.032    -.9911512   -.0453777
----------------+----------------------------------------------------------------
3               |
         female |   .0478491   .1642986     0.29   0.771    -.2741701    .3698684
resp_agecat_gr2 |  -.0377596   .2785256    -0.14   0.892    -.5836597    .5081405
resp_agecat_gr3 |   .2814933   .2734043     1.03   0.303    -.2543693    .8173559
resp_agecat_gr4 |   .6099866   .2906964     2.10   0.036     .0402322    1.179741
resp_agecat_gr5 |   .8237896   .3185856     2.59   0.010     .1993734    1.448206
       higheduc |   .9818211   .1709095     5.74   0.000     .6468447    1.316798
          union |   .2610096   .2215236     1.18   0.239    -.1731687     .695188
      _Irelig_2 |   .0056292    .217959     0.03   0.979    -.4215626    .4328209
      _Irelig_3 |   .3574542   .1835881     1.95   0.052    -.0023718    .7172802
      franconia |  -.0643732    .173223    -0.37   0.710    -.4038841    .2751377
      govecopos |   -.920618   .2090477    -4.40   0.000    -1.330344   -.5108921
      goveconeg |   .0186982   .2256837     0.08   0.934    -.4236337    .4610302
          _cons |  -1.724466   .3092012    -5.58   0.000    -2.330489   -1.118442
----------------+----------------------------------------------------------------
4               |
         female |  -.3737112   .1464625    -2.55   0.011    -.6607724   -.0866501
resp_agecat_gr2 |  -.0321976   .2418037    -0.13   0.894    -.5061241    .4417289
resp_agecat_gr3 |   .0707716   .2427845     0.29   0.771    -.4050773    .5466205
resp_agecat_gr4 |   .5380444   .2560563     2.10   0.036     .0361833    1.039905
resp_agecat_gr5 |   .3081967   .2855492     1.08   0.280    -.2514695    .8678628
       higheduc |   .1879088   .1467852     1.28   0.200     -.099785    .4756025
          union |   .2779478   .1914688     1.45   0.147    -.0973241    .6532196
      _Irelig_2 |   .2036134   .1841999     1.11   0.269    -.1574118    .5646386
      _Irelig_3 |   .0525602   .1686959     0.31   0.755    -.2780776    .3831981
      franconia |  -.3704208   .1558101    -2.38   0.017    -.6758029   -.0650387
      govecopos |  -.5740853   .1659579    -3.46   0.001    -.8993569   -.2488138
      goveconeg |   .0287264   .2083011     0.14   0.890    -.3795363     .436989
          _cons |  -.5529405   .2631703    -2.10   0.036    -1.068745   -.0371363
----------------+----------------------------------------------------------------
5               |
         female |  -.3456152    .191435    -1.81   0.071    -.7208209    .0295905
resp_agecat_gr2 |   .4889344   .3466321     1.41   0.158    -.1904521    1.168321
resp_agecat_gr3 |   .6535481   .3460755     1.89   0.059    -.0247475    1.331844
resp_agecat_gr4 |   .6902732   .3842433     1.80   0.072    -.0628297    1.443376
resp_agecat_gr5 |   1.117942   .3844651     2.91   0.004     .3644044     1.87148
       higheduc |   .8723042   .1974582     4.42   0.000     .4852933    1.259315
          union |  -.5265965   .3142166    -1.68   0.094     -1.14245    .0892567
      _Irelig_2 |   .1461244   .2472049     0.59   0.554    -.3383883    .6306372
      _Irelig_3 |   .3246764   .2100592     1.55   0.122    -.0870321    .7363849
      franconia |  -.1075507   .1994342    -0.54   0.590    -.4984346    .2833332
      govecopos |   .0591889   .1935406     0.31   0.760    -.3201438    .4385216
      goveconeg |  -.5032869   .3564685    -1.41   0.158    -1.201952    .1953785
          _cons |  -2.343744   .3858767    -6.07   0.000    -3.100048   -1.587439
----------------+----------------------------------------------------------------
6               |
         female |  -.6315561   .2639792    -2.39   0.017    -1.148946   -.1141665
resp_agecat_gr2 |   .8172013   .5633111     1.45   0.147    -.2868681    1.921271
resp_agecat_gr3 |   .6879083   .5663729     1.21   0.225    -.4221622    1.797979
resp_agecat_gr4 |    .787614   .5902548     1.33   0.182    -.3692641    1.944492
resp_agecat_gr5 |   1.309535   .5993088     2.19   0.029     .1349111    2.484158
       higheduc |  -.5659792   .2787136    -2.03   0.042    -1.112248   -.0197106
          union |   .4070814    .314753     1.29   0.196    -.2098231    1.023986
      _Irelig_2 |   .1228916   .3713559     0.33   0.741    -.6049526    .8507357
      _Irelig_3 |   1.205947   .3051832     3.95   0.000      .607799    1.804095
      franconia |   .5581519   .2660842     2.10   0.036     .0366365    1.079667
      govecopos |  -1.360782   .4458585    -3.05   0.002    -2.234649   -.4869155
      goveconeg |   .9245317   .2927175     3.16   0.002      .350816    1.498247
          _cons |  -2.578517   .6032191    -4.27   0.000    -3.760805    -1.39623
---------------------------------------------------------------------------------

. * N = 2845
. predict prob_second // mean probability of second vote (also predict for cases out of
>  sample)
(option pr assumed; Pr(party_num))

. 
. * check: is csu vote correctly predicted?
. gen csu_correct = 0 if party_num == 1 & psecondvote != . 
(19,869 missing values generated)

. replace csu_correct = 1 if csu_correct == 0 & party_num == 1 & ( (psecondvote == 1 & 
> prob_second > .5 & prob_second != .) |  ( psecondvote == 0  & prob_second < .5))
(2,267 real changes made)

. tab csu_correct if party_num == 1

csu_correct |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      1,282       36.12       36.12
          1 |      2,267       63.88      100.00
------------+-----------------------------------
      Total |      3,549      100.00

. tab csu_correct if party_num == 1 & e(sample)

csu_correct |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        578       20.32       20.32
          1 |      2,267       79.68      100.00
------------+-----------------------------------
      Total |      2,845      100.00

. 
. *********************************
. ** write data used for graph in R
. *********************************
. 
. keep if party_num == 1 // data is in long format; need each respondent only once
(19,515 observations deleted)

. drop if prob_second == . 
(491 observations deleted)

. keep affair_vimp prob_second  affair affair_run affair_norun vintpol wk_inconsistent

. saveold "survey\medw_out_forgraph.dta", replace version(12)
(saving in Stata 12 format, which can be read by Stata 11 or 12)
file survey\medw_out_forgraph.dta saved

. 
. 
. ****************************************************************************
. ** Self-reported affair importance by candidate vote (as reported in text)
. ****************************************************************************
. 
. use "survey\medw_out.dta", clear

. ren list_pre listrank

. 
. gen RBEZ_name = ""
(23,418 missing values generated)

. local wk "Oberbayern Niederbayern Oberpfalz Oberfranken Mittelfranken Unterfranken Sc
> hwaben"

. forvalues i = 1/7 {
  2. local w: word `i' of `wk'
  3. replace RBEZ_name = "`w'" if wk_num == `i'
  4. }
variable RBEZ_name was str1 now str10
(9,444 real changes made)
variable RBEZ_name was str10 now str12
(1,716 real changes made)
(1,896 real changes made)
(2,172 real changes made)
variable RBEZ_name was str12 now str13
(3,576 real changes made)
(2,442 real changes made)
(2,034 real changes made)

. 
. keep if party_num == 1 // data is in long format; need each respondent only once
(19,515 observations deleted)

. * keep only CSU second vote voters, and outside Mittelfranken (where no candidate on 
> list was implicated) 
. keep if psecondcsu == 1 & wk_num != 5 
(2,691 observations deleted)

. * merge info re inclusion in matching sample  (by region name and list rank)
. * this is matching sample 3 with N = 45
. merge m:1 RBEZ listrank using "survey\cem_model43.dta"

    Result                           # of obs.
    -----------------------------------------
    not matched                         1,121
        from master                     1,109  (_merge==1)
        from using                         12  (_merge==2)

    matched                               103  (_merge==3)
    -----------------------------------------

. drop if _m == 2 // these are N = 12 matched candidates that were never mentioned by s
> urvey respondents as their choice
(12 observations deleted)

. ren _m cem_verybroad

. recode cem_very (1 =0) (3 =1)
(cem_verybroad: 1212 changes made)

. lab val cem

. * N = 103 respondents (from among CSU second vote voters, and outside Mittelfranken) 
> chose any matched candidate (implicated or not)
. 
. tab candnumbername, m // candidate vote info among CSU second vote voters outside Mit
> telfranken

                         candnumbername |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
                                        |        144       11.88       11.88
                    102    Aigner, Ilse |         51        4.21       16.09
                    102    Eck, Gerhard |          1        0.08       16.17
 102    Freiherr von Lerchenfeld, Lud.. |         10        0.83       17.00
                      102    Gibis, Max |          3        0.25       17.24
                  102    Hierl, Susanne |          9        0.74       17.99
                 102    Kreuzer, Thomas |          4        0.33       18.32
                    103    Demar, Josef |          2        0.17       18.48
             103    Dr. Spaenle, Ludwig |          6        0.50       18.98
               103    Schorer, Angelika |          1        0.08       19.06
                     103    Sem, Reserl |          2        0.17       19.22
                    103    Thoma, Julia |          1        0.08       19.31
          104    Haderthauer, Christine |         10        0.83       20.13
         104    Hintersberger, Johannes |         14        1.16       21.29
                 104    Popp, Elisabeth |          6        0.50       21.78
                104    Rudrof, Heinrich |          3        0.25       22.03
                   104    Sibler, Bernd |          2        0.17       22.19
                   104    Wende, Martin |          1        0.08       22.28
                  105    Beer, Matthias |          1        0.08       22.36
               105    Dr. Huber, Marcel |          5        0.41       22.77
               105    Fasching, Marlies |          4        0.33       23.10
                 105    Gerlach, Judith |         10        0.83       23.93
                  105    H�lzl, Florian |          6        0.50       24.42
               106    Bocklet, Reinhold |          2        0.17       24.59
             106    Dr. Reichhart, Hans |          7        0.58       25.17
                106    Heike, J�rgen W. |          1        0.08       25.25
                     106    Ott, Stefan |          3        0.25       25.50
                      106    Ritt, Hans |         14        1.16       26.65
               107    Dworacek, Melanie |          2        0.17       26.82
                  107    Ho�mann, Maria |          3        0.25       27.06
                    107    Koller, Hans |          3        0.25       27.31
              107    Nachtigall, Dagmar |          3        0.25       27.56
                107    Sch�ffel, Martin |          2        0.17       27.72
            107    Wittmann, Mechthilde |          2        0.17       27.89
                108    Bei�wenger, Eric |          9        0.74       28.63
               108    Dr. Huber, Martin |          5        0.41       29.04
          108    Glufke-B�hm, Alexandra |          8        0.66       29.70
                  108    Greif, Hermann |          2        0.17       29.87
                   108    Houben, Frank |          4        0.33       30.20
             108    H�gl, Petra Therese |          4        0.33       30.53
               109    Bittner, Reinhold |          1        0.08       30.61
              109    Dettenh�fer, Petra |          2        0.17       30.78
                 109    Klein, Burkhard |          1        0.08       30.86
                109    Kreitmair, Anton |          3        0.25       31.11
                  109    Stapfer, Adolf |          2        0.17       31.27
                    109    Then, Holger |          2        0.17       31.44
               110    Dr. Hohl, Michael |         15        1.24       32.67
               110    Eisenreich, Georg |          8        0.66       33.33
               110    Flierl, Alexander |          2        0.17       33.50
              110    H�tzinger, Irmgard |          2        0.17       33.66
           110    Lippert, Sorya-Leonie |          4        0.33       33.99
                111    F�racker, Albert |          1        0.08       34.08
               111    Hausberger, Luise |          3        0.25       34.32
                    111    Link, Marion |          2        0.17       34.49
               111    Losinger, Manfred |         11        0.91       35.40
                 111    Mandoki, Leslie |          4        0.33       35.73
                   111    Passow, Karin |          2        0.17       35.89
            112    Dr. Hogrefe, G�nther |          5        0.41       36.30
    112    Prof. Dr. Bausback, Winfried |          3        0.25       36.55
                  112    Reiter, Martin |          3        0.25       36.80
               113    Czepluch, Stephan |          2        0.17       36.96
                      113    Dietz, Leo |          3        0.25       37.21
              113    Dr. Goppel, Thomas |         11        0.91       38.12
            113    Dr. H�nnerkopf, Otto |          1        0.08       38.20
                    113    Huber, Erwin |          8        0.66       38.86
                     114    Boldt, Ren� |          4        0.33       39.19
               114    Dr. Rieger, Franz |         13        1.07       40.26
                 114    Heckner, Ingrid |          3        0.25       40.51
                    114    J�rg, Oliver |          1        0.08       40.59
                115    Kirchner, Sandro |          1        0.08       40.68
               115    Radlmeier, Helmut |          1        0.08       40.76
                115    Schreder, Thomas |          8        0.66       41.42
               116    Bachhuber, Martin |          5        0.41       41.83
                116    L�ndner, Manfred |          2        0.17       42.00
                      116    Mai, Armin |          4        0.33       42.33
                 116    Rose, Christian |          4        0.33       42.66
            116    Stierstorfer, Sylvia |          2        0.17       42.82
              116    Taubeneder, Walter |          2        0.17       42.99
                 117    Briechle, Erwin |          1        0.08       43.07
           117    Dr. Waschler, Gerhard |          3        0.25       43.32
                   118    Blume, Markus |          3        0.25       43.56
            119    Brannekamper, Robert |          4        0.33       43.89
               119    Holetschek, Klaus |          1        0.08       43.98
                  119    Vogel, Steffen |          2        0.17       44.14
                     120    Dorow, Alex |          1        0.08       44.22
                  120    Kr�nzle, Bernd |          1        0.08       44.31
                   120    Winter, Peter |          1        0.08       44.39
           121    Dr. Eiling-H�tig, Ute |          1        0.08       44.47
          121    Pschierer, Franz Josef |          2        0.17       44.64
                  123    Sauter, Alfred |          1        0.08       44.72
           124    Dr. Herrmann, Florian |          1        0.08       44.80
                124    Tomaschko, Peter |          1        0.08       44.88
              125    Trautner, Carolina |          1        0.08       44.97
                   128    Lederer, Otto |          1        0.08       45.05
                 129    Lorenz, Andreas |          2        0.17       45.21
                   130    Meyer, Markus |          2        0.17       45.38
                  134    Scharf, Ulrike |          2        0.17       45.54
           135    Schorer-Dremel, Tanja |          1        0.08       45.63
                   137    Seeger, Heino |          1        0.08       45.71
                  139    Steiner, Klaus |          1        0.08       45.79
                 140    St�ttner, Klaus |          1        0.08       45.87
                    141    Straub, Karl |          1        0.08       45.96
            142    Unterlander, Joachim |          1        0.08       46.04
              143    Weichenrieder, Max |          2        0.17       46.20
              144    Weidenbusch, Ernst |          2        0.17       46.37
                 101    Brunner, Helmut |         22        1.82       48.18
                 101    Dr. Merk, Beate |         15        1.24       49.42
                   101    Huml, Melanie |         38        3.14       52.56
                  101    M�ller, Emilia |         38        3.14       55.69
                 101    Seehofer, Horst |        354       29.21       84.90
                  101    Stamm, Barbara |         78        6.44       91.34
                             Don't know |         55        4.54       95.87
       General vote for <Party from Q7> |         48        3.96       99.83
                           Invalid vote |          2        0.17      100.00
----------------------------------------+-----------------------------------
                                  Total |      1,212      100.00

. di 1-((144 + 55 ) /1212) // 84% not missing and not Don't know
.83580858

. 
. * Cross-tab of 'vote for implicated candidate' and "self-report: affair important".
. * (those who voted for matched candidates, and who also voted CSU with first vote)
. tab affair affair_imp if cem_very == 1 & pfirstvote == 1, row

+----------------+
| Key            |
|----------------|
|   frequency    |
| row percentage |
+----------------+

CSU affair |
 candidate |      affair_imp
   in 2013 |         0          1 |     Total
-----------+----------------------+----------
         0 |        70         16 |        86 
           |     81.40      18.60 |    100.00 
-----------+----------------------+----------
         1 |        10          0 |        10 
           |    100.00       0.00 |    100.00 
-----------+----------------------+----------
     Total |        80         16 |        96 
           |     83.33      16.67 |    100.00 


. assert wk_inconsistent == 0 if cem_very == 1 & pfirstvote == 1

. 
. log close
      name:  <unnamed>
       log:  C:\Dropbox\bavarian affair\merged data\replication\survey\survey_2014.log
  log type:  text
 closed on:  20 Nov 2015, 18:53:29
---------------------------------------------------------------------------------------
